import Mock from 'mockjs'
let List = []
for (var i = 0; i < 6; i++) {
  List.push({
    id: Mock.mock('@guid'),
    code: 10001 + i,
    name: Mock.mock('@integer(0, 2)'), //0代表头孢颗粒 1代表vc银翘片 2代表999感冒灵
    regular: "药品规格",
    input: Mock.mock('@integer(1, 1)'),
    input1: Mock.mock('@integer(1, 1)'),
    input2: Mock.mock('@integer(10, 15)'),
    input3: Mock.mock('@integer(18, 20)'),
  })
}
let addArr = []
for (var i = 0; i < 10; i++) {
  addArr.push({
    queque: 1000001 + i,
    name: Mock.mock('@integer(0, 9)'), //0代表兰索拉唑肠溶片，1代表甲钴胺片，2代表复方求唑沙宗胶囊,3代表对乙酰氨基酚片，4代表双嘧达膜片，5代表阿莫西林胶囊，6代表骨肽注射液，7代表双氯扽双那肠溶片，8代表滴眼用利福平，9代表红霉素眼膏
    add: "添加",
  })
}
export default {
  addDrugData: config => {
    let {
      queque,
      name,
      add
    } = JSON.parse(config.body)
    addArr.push({
      queque: queque,
      name: name, //0代表兰索拉唑肠溶片，1代表甲钴胺片，2代表复方求唑沙宗胶囊,3代表对乙酰氨基酚片，4代表双嘧达膜片，5代表阿莫西林胶囊，6代表骨肽注射液，7代表双氯扽双那肠溶片，8代表滴眼用利福平，9代表红霉素眼膏
      add: "添加",
    })
    return {
      code: 200,
      msg: '添加成功',
      data: null
    }
  },
  getDrugData: (config) => {
    return {
      code: 200,
      msg: '请求成功',
      data: List
    }
  },
  removeDrugData: config => {
    // console.log('config',config);
    let {
      id
    } = JSON.parse(config.body)
    let newList = List.filter(item => {
      return item.id != id
    })
    List = newList
    return {
      code: 200,
      msg: '删除成功',
      data: null
    }
  },
  creaseDrugData: config => {
    let {
      index,
      code,
      name,
      regular
    } = JSON.parse(config.body)
    List.push({
      id: Mock.mock('@guid'),
      index: index,
      code: code,
      name: name, //0代表头孢颗粒 1代表vc银翘片 2代表999感冒灵
      regular: regular,
      input: Mock.mock('@integer(1, 1)'),
      input1: Mock.mock('@integer(1, 1)'),
      input2: Mock.mock('@integer(10, 15)'),
      input3: Mock.mock('@integer(18, 20)'),
    })
    return {
      code: 200,
      msg: '添加成功',
      data: null
    }
  },
  creasePhangData: (config) => {
    return {
      code: 200,
      msg: '请求成功',
      data: addArr
    }
  }
}